home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
macros
/
latex209
/
contrib
/
misc
/
settosize.sty
< prev
next >
Wrap
Text File
|
1993-02-17
|
1KB
|
51 lines
%%% The user needs to be able to specify the width for text, and
%%% use the largest point size necessary to fill that width.
%%%
%%% After macros by Phil Taylor January 1993;
%%% converted to LaTeX style file (needs NFSS) and changed syntax
%%% by Sebastian Rahtz, February 1993.
%%% \Fontname: like \fontname, but voids any size specifier
%%% Usage: \Fontname \font {} %%% don't omit {} !!!
\edef \Fontname
{\noexpand \expandafter \noexpand \stripsize \noexpand \fontname \space}
\def \stripsize #1 #2#{#1}
\newcount \pts@f@r
\newdimen \set@width
\def\massage@fontname#1 #2:{\def\curr@fontname{#1}}
\def \scaletowidth#1#2{%
\set@width #1
\edef\f@name{\fontname\font\space:}%
\expandafter\massage@fontname\f@name
\pts@f@r \f@size
\setbox 0 = \hbox{#2}%
\ifdim \wd 0 < \set@width
\def\@increment{1}%
\def\@test{<}%
\else
\def\@increment{-1}%
\def\@test{>}%
\fi
\loop
\font\temp@font=\curr@fontname\space at \the\pts@f@r pt
\setbox 0 = \hbox{{\temp@font #2}}%
\message {\curr@fontname->\the \pts@f@r...}%
\ifdim \wd 0 \@test \set@width
\advance \pts@f@r by \@increment
\repeat
\advance \pts@f@r by -\@increment
\message {The calculated font size is \the \pts@f@r pt}%
\font\temp@font=\curr@fontname\space at \the\pts@f@r pt
\hbox to \set@width {\hss{\temp@font #2}\hss}%
}
\endinput
Example:
\scaletowidth{50cm}{Now is the time for the Party}